package com.cz.video.website.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cz.video.common.core.domain.BaseEntity;
import com.cz.video.common.core.validate.AddGroup;
import com.cz.video.common.xss.Xss;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.experimental.Delegate;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Null;
import javax.validation.constraints.Pattern;
import java.io.Serial;
import java.io.Serializable;

/**
 * <p>
 * 首页banner表
 * </p>
 *
 * @author yr
 * @since 2023-10-15
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("website_banner")
@Schema(description="首页banner表")
public class WebsiteBanner extends BaseEntity implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Null(groups = AddGroup.class,message = "新增轮播图id不能手动添加")
    @TableId(value = "banner_id")
    private Integer bannerId;

    @Delegate
    @Schema( description = "标题")
    @Length(max=20,message = "标题不能超过{max}个字符")
    @NotBlank(message = "用户昵称不能为空",groups = AddGroup.class)
    @Xss(message = "不可使用文本文件")
    private String title;

    @Schema( description = "图片地址")
    @NotBlank(message = "图片地址不能为空")
    @Pattern(regexp="\\.(jpg|jpeg|png)$", message="只允许上传jpg、jpeg、png格式的图片")
    private String imageUrl;

    @Schema( description = "链接地址")
    @NotBlank(message = "链接地址不能为空")
    private String linkUrl;

    @Schema( description = "排序")
    private Integer sort;

    @Schema( description = "是否展示")
    @JsonProperty("isExhibition")
    @TableField("is_exhibition")
    private Boolean exhibition;

    @TableLogic
    @Schema( description = "逻辑删除 2（true）已删除， 0（false）未删除")
    private String delFlag;

    @Schema( description = "备注")
    @Length(max=50,message = "标题不能超过{max}个字符")
    private String remark;

}
